﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using GameObjects;
using GameObjects.Values;

namespace GameProcess.Actors
{
    class ScoresActor : IActor, IPacketHandler
    {
        GameState _gameState;

        public ScoresActor(GameState gameState)
        {
            this._gameState = gameState;
        }

        public void UpdateClient(GameTime gameTime)
        {
            // запрос на статистику игры по просьбе игрока
            _gameState.NetPlayer.ClientPacket.ClientQuery = Commands.ScoresButtonPressed ?
                Virvar.Net.ClientQuery.Scores :
                Virvar.Net.ClientQuery.None;
        }

        public void UpdateServer(GameTime gameTime)
        {
        }

        public void ReceiveClient(Virvar.Net.ServerPacket msg)
        {
            if (msg.Scores != null)
            {
                _gameState.Scores = msg.Scores;
            }
        }

        public void ReceiveServer(Virvar.Net.ClientPacket msg)
        {
            // отправить клиенту статистку игры, если нужно
            _gameState.NetPlayers[msg.PlayerId].ServerPacket.Scores = (msg.ClientQuery == Virvar.Net.ClientQuery.Scores) ?
                _gameState.Scores :
                null;
        }
    }
}
